package com.example.demo.demos.web.Utils;

import com.example.demo.demos.web.po.CommonData;
import com.example.demo.demos.web.po.SystemData;
import org.apache.poi.xwpf.usermodel.*;

import java.io.FileInputStream;
import java.util.Map;

/**
 * @BelongsProject: demo1
 * @BelongsPackage: com.example.demo.demos.web.Utils
 * @Author: Hu1er
 * @CreateTime: 2023-07-04  11:44
 * @Description: TODO
 * @Version: 1.0
 */


public class Test {
    public static void main(String[] args) throws Exception {
        //模板文件地址
        String templateDocPath = "/Users/hu1er/IdeaProjects/demo1/src/main/resources/template/template.docx";
        //报告文件目录
        String reportPath = "/Users/hu1er/IdeaProjects/demo1/src/main/resources/report/report1.docx";

        FileInputStream fis = new FileInputStream(templateDocPath);
        XWPFDocument  document = new XWPFDocument(fis);

        CommonData commonDatatest = new CommonData();
        SystemData systemData = new SystemData();
        commonDatatest.setCustomname("启明星辰信息安全技术有限公司");
        commonDatatest.setSystemname("OA办公系统");
        commonDatatest.setMaker("刘伊凡");
        commonDatatest.setAuditer("王复员");
        commonDatatest.setStartdate(new java.sql.Date(2020,12,13));
        commonDatatest.setEnddata(new java.sql.Date(2020,12,14));
        systemData.setSystemurl("http://127.0.0.1/test");


        Map<String,String> dict = Utils.getCommonData(commonDatatest,systemData);
        Utils.copyAndReplace(document,reportPath,dict);

/*        for (int i = 0; i < 3; i++) {
            Utils.createTable(document,reportPath);
        }*/

        System.out.println("新文件已生成！");
    }
}
